local LogUtility = require("Utility/LogUtility")

local helloworldCom = CS.UnityEngine.GameObject.Find("Hello World"):GetComponent(typeof(CS.HelloWorld))

function TestFunc()
    LogUtility.Log("------------------")
    -- coroutine.resume(co)
end

function foo()
    LogUtility.Log("协同程序 foo 开始执行")
    local value = coroutine.yield(helloworldCom:LongRunningOperation(TestFunc))
    LogUtility.Log("协同程序 foo 恢复执行，传入的值为: " .. tostring(value))
    LogUtility.Log("协同程序 foo 结束执行")
end

-- 创建协同程序
co = coroutine.create(foo)

-- 启动协同程序
local status, result = coroutine.resume(co)
-- LogUtility.Log(result) 
status, result = coroutine.resume(co)
-- LogUtility.Log(result) 

